---------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Dropbox\bavarian affair\merged data\replication\tables\substantive_size
> .log
  log type:  text
 opened on:  21 Nov 2015, 15:01:58

. 
. use tables\candidates_csu_replication.dta, clear

. keep if year == 2013
(73 observations deleted)

. decode rbez, gen(wk)

. replace wk = subinstr(wk,"OLPR ballot ","",.)
(164 real changes made)

. gen listrank = list_pre

. merge 1:1 year wk listrank using tables\votes2013, keepusing(gew) // merge info regar
> ding whether elected or not (data from election authorities)

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                               164  (_merge==3)
    -----------------------------------------

. assert _m == 3 

. 
. byso wk: egen listlength = max(listrank)

. gen tmp = gew != ""

. by wk: egen sum_elected_region = total(tmp)

. drop tmp

. 
. * sort by regional district (wk) and ranking based on second vote (defined as for the
>  dep. var. in the analyses)
. gsort wk -sv_cand

. by wk: gen svcandrank = _n

. 
. by wk: gen winlosediff = sv_cand-sv_cand[_n-1] if svcandrank == sum_elected_region + 
> 1
(157 missing values generated)

. table wk, c(mean listlength mean sum_elected_region mean winlose)

--------------------------------------------------------------
Electoral     |
districts     | mean(listle~h)  mean(sum_el~n)  mean(winlos~f)
--------------+-----------------------------------------------
Mittelfranken |             24              12       -.2155974
 Niederbayern |             18              11       -1.145354
   Oberbayern |             44              33       -.0052256
  Oberfranken |             16               9       -.1876338
    Oberpfalz |             16               9       -.1430888
     Schwaben |             26              15       -.1795068
 Unterfranken |             20              12       -.0088319
--------------------------------------------------------------

. * br wk listrank svcandrank sv_cand sum_elected
. 
. 
. log close
      name:  <unnamed>
       log:  C:\Dropbox\bavarian affair\merged data\replication\tables\substantive_size
> .log
  log type:  text
 closed on:  21 Nov 2015, 15:01:58
---------------------------------------------------------------------------------------
